import { defineStore } from 'pinia'

export const useUserStore = defineStore('user', {
  state: () => ({
    user: {
      id: '',
      username: '',
      email: '',
      avatar: ''
    },
    token: ''
  }),
  actions: {
    setUser(u: any) {
      this.user = u
      this.setToken(u.token)
    },
    setToken(t: string) {
      this.token = t
    }
  }
})
